package com.ssy.lingxi.settle.accounts.entity;

import com.fasterxml.jackson.annotation.JsonManagedReference;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 业务对账单DO
 * @author Saske
 * @date 2021/12/7
 * @version 2.0.0
 */
@Entity
@Table(schema = "public",name = "sa_business_reconciliation",
indexes = {@Index(name = "sa_business_reconciliation_reconciliation_no_idx",columnList = "reconciliationNo",unique = true),
        @Index(name = "sa_business_reconciliation_vendor_member_id_idx",columnList = "vendorMemberId"),
        @Index(name = "sa_business_reconciliation_vendor_role_id_idx",columnList = "vendorRoleId"),
        @Index(name = "sa_business_reconciliation_status_idx",columnList = "status"),
        @Index(name = "sa_business_reconciliation_abs_idx",columnList = "reconciliationAbstract"),
        @Index(name = "sa_business_reconciliation_payer_idx",columnList = "payer"),
        @Index(name = "sa_business_reconciliation_payee_idx",columnList = "payee"),
        @Index(name = "sa_business_reconciliation_buyer_member_id_idx",columnList = "buyerMemberId"),
        @Index(name = "sa_business_reconciliation_buyer_role_id_idx",columnList = "buyerRoleId"),
        @Index(name = "sa_business_reconciliation_createTime_idx",columnList = "createTime"),

})
public class BusinessReconciliationDO implements Serializable {

    private static final long serialVersionUID = -1590204681655248741L;

    /**
     * ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "statement_reconciliation_seq")
    @SequenceGenerator(sequenceName = "sa_statement_reconciliation_seq", name = "statement_reconciliation_seq", allocationSize = 1)
    private Long id;

    /**
     * 对账单号
     */
    @Column(name = "reconciliationNo",columnDefinition = "varchar(50)")
    private String reconciliationNo;

    /**
     * 对账单状态，定义在ReconciliationStatusEnum
     */
    @Column(name = "status")
    private Integer status;

    /**
     * 外部状态，定义在ReconciliationOuterStatusEnum中
     */
    @Column(name = "outerStatus")
    private Integer outerStatus;

    /**
     * 发票状态
     */
    @Column(name = "InvoiceStatus")
    private Integer InvoiceStatus;

    /**
     * 对账单类型
     */
    @Column(name = "reconciliationType")
    private Integer reconciliationType;

    /**
     * 对账单摘要
     */
    @Column(name = "reconciliationAbstract",columnDefinition = "varchar(60)")
    private String reconciliationAbstract;

    /**
     * 付款方
     */
    @Column(name = "payer")
    private String payer;

    /**
     * 收款方
     */
    @Column(name = "payee")
    private String payee;

    /**
     * 发起对帐方
     */
    @Column(name = "launchReconciliation")
    private String launchReconciliation;

    /**
     * 待对账金额（含税）
     */
    @Column(name = "reconciliationMoneyAmount",columnDefinition = "decimal")
    private BigDecimal reconciliationMoneyAmount;

    /**
     * 备注
     */
    @Column(name = "remark")
    private String remark;

    /**
     * 单据时间
     */
    @Column(name = "createTime")
    private LocalDateTime createTime;

    /**
     * 买方（采购）会员Id
     */
    @Column
    private Long buyerMemberId;

    /**
     * 买方（采购）会员角色Id
     */
    @Column
    private Long buyerRoleId;

    /**
     * 卖方（供应）会员Id
     */
    @Column
    private Long vendorMemberId;

    /**
     * 卖方（供应）会员角色Id
     */
    @Column
    private Long vendorRoleId;

    /**
     * 一对多双向关联对账单行明细
     */
    @JsonManagedReference
    @OneToMany(mappedBy = "reconciliation", cascade = {CascadeType.PERSIST, CascadeType.REMOVE, CascadeType.MERGE}, fetch = FetchType.LAZY)
    private List<BusinessReconciliationRowDO> rows;

    /**
     * 流程任务id
     */
    @Column
    private String taskId;

    /**
     * 下一步骤，如果为0表示流程已经结束，没有下一步
     */
    @Column
    private Integer otherNextStep;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getReconciliationNo() {
        return reconciliationNo;
    }

    public void setReconciliationNo(String reconciliationNo) {
        this.reconciliationNo = reconciliationNo;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getOuterStatus() {
        return outerStatus;
    }

    public void setOuterStatus(Integer outerStatus) {
        this.outerStatus = outerStatus;
    }

    public Integer getInvoiceStatus() {
        return InvoiceStatus;
    }

    public void setInvoiceStatus(Integer invoiceStatus) {
        InvoiceStatus = invoiceStatus;
    }

    public Integer getReconciliationType() {
        return reconciliationType;
    }

    public void setReconciliationType(Integer reconciliationType) {
        this.reconciliationType = reconciliationType;
    }

    public String getReconciliationAbstract() {
        return reconciliationAbstract;
    }

    public void setReconciliationAbstract(String reconciliationAbstract) {
        this.reconciliationAbstract = reconciliationAbstract;
    }

    public String getPayer() {
        return payer;
    }

    public void setPayer(String payer) {
        this.payer = payer;
    }

    public String getPayee() {
        return payee;
    }

    public void setPayee(String payee) {
        this.payee = payee;
    }

    public String getLaunchReconciliation() {
        return launchReconciliation;
    }

    public void setLaunchReconciliation(String launchReconciliation) {
        this.launchReconciliation = launchReconciliation;
    }

    public BigDecimal getReconciliationMoneyAmount() {
        return reconciliationMoneyAmount;
    }

    public void setReconciliationMoneyAmount(BigDecimal reconciliationMoneyAmount) {
        this.reconciliationMoneyAmount = reconciliationMoneyAmount;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    public Long getBuyerMemberId() {
        return buyerMemberId;
    }

    public void setBuyerMemberId(Long buyerMemberId) {
        this.buyerMemberId = buyerMemberId;
    }

    public Long getBuyerRoleId() {
        return buyerRoleId;
    }

    public void setBuyerRoleId(Long buyerRoleId) {
        this.buyerRoleId = buyerRoleId;
    }

    public Long getVendorMemberId() {
        return vendorMemberId;
    }

    public void setVendorMemberId(Long vendorMemberId) {
        this.vendorMemberId = vendorMemberId;
    }

    public Long getVendorRoleId() {
        return vendorRoleId;
    }

    public void setVendorRoleId(Long vendorRoleId) {
        this.vendorRoleId = vendorRoleId;
    }

    public List<BusinessReconciliationRowDO> getRows() {
        return rows;
    }

    public void setRows(List<BusinessReconciliationRowDO> rows) {
        this.rows = rows;
    }

    public String getTaskId() {
        return taskId;
    }

    public void setTaskId(String taskId) {
        this.taskId = taskId;
    }

    public Integer getOtherNextStep() {
        return otherNextStep;
    }

    public void setOtherNextStep(Integer otherNextStep) {
        this.otherNextStep = otherNextStep;
    }
}
